<%--
  Created by IntelliJ IDEA.
  User: hp
  Date: 2019/1/15
  Time: 13:43
  To change this template use File | Settings | File Templates.
--%>
<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<html>
<head>
    <title>会员统计</title>
    <jsp:include page="${pageContext.request.contextPath}/common/tag.jsp"/>
</head>
<body>
    <!-- 为ECharts准备一个具备大小（宽高）的Dom -->
    <div id="main" style="width: 600px;height:400px;"></div>
</body>
    <script type="text/javascript">
        $.post("${pageContext.request.contextPath}/tongji/membertongji",function (data) {
            var rs = [];
            $.each(data,function () {
                rs.push({
                    name :this.tname,
                    value:this.num
                });
            });
            // 基于准备好的dom，初始化echarts实例
            var member = echarts.init(document.getElementById('main'));
            option = {
                title : {
                    text: '会员类型统计',
                    x:'center'
                },
                tooltip : {
                    trigger: 'item',
                    formatter: "{a} <br/>{b} : {c} ({d}%)"
                },
                legend: {
                    orient: 'vertical',
                    left: 'left',
                    data: data.tname
                },
                series : [
                    {
                        name: '数量',
                        type: 'pie',
                        radius : '55%',
                        center: ['50%', '60%'],
                        data:rs,
                        itemStyle: {
                            emphasis: {
                                shadowBlur: 10,
                                shadowOffsetX: 0,
                                shadowColor: 'rgba(0, 0, 0, 0.5)'
                            }
                        }
                    }
                ]
            };
            // 使用刚指定的配置项和数据显示图表。
            member.setOption(option);
        })
    </script>
</html>
